package com.bwie.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/7/21 20:29
 */

@Configuration
public class MyThreadPool {

    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                4,      // 核心线程数
                8,                 // 最大线程数
                0L,                 // 线程空闲时间
                TimeUnit.MILLISECONDS,  // 时间单位
                new LinkedBlockingQueue<Runnable>(),    // 任务队列
                Executors.defaultThreadFactory());      // 线程工厂

        return threadPoolExecutor;
    }

}
